<template>
  <div class="animated fadeIn">
    <div class="row">
      <div class="col-lg-12">
        <b-card header="<i class='fa fa-align-justify'></i> RFI报价详情">
          <div class="table-box">
            <table class="table table-striped">
              <thead>
              <tr>
                <th>商品编号</th>
                <th>代码</th>
                <th>数量</th>
                <th>单价</th>
                <th>总计</th>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td colspan="5" v-show="isQuote" style="text-align: center;">没有搜索到匹配的信息!</td>
              </tr>
              <tr  v-for="(item, index) in dataList">
                <td>{{ item.productno }}</td>
                <td>{{ item.code }}</td>
                <td>{{ item.amount }}</td>
                <td>{{ item.price }}</td>
                <td>{{ item.total }}</td>
              </tr>
              </tbody>
            </table>
          </div>
          <div slot="footer">
            <b-button type="submit" size="sm" variant="primary" @click="backRfiDetail()">
              <i class="fa fa-dot-circle-o"></i> 返回
            </b-button>
          </div>
        </b-card>
      </div>
    </div>
  </div>
</template>

<script>
  import { findQuotationById } from '../../service/api'
  export default {
    name: 'forms',
    data () {
      return {
        dataList: [],
        isQuote: false
      }
    },
    methods: {
      backRfi () {
        this.$router.push({
          path: '/information/rfi'
        })
      },
      backRfiDetail () {
        this.$router.push({
          path: '/information/rfi'
        })
      }
    },
    created () {
      findQuotationById({id: this.$route.query.id})
        .then(({ data, err }) => {
          console.log('err: ' + err)
          console.log('data: ' + data)
          if (data.code === 200) {
            this.dataList = data.result
            for (const i in this.dataList) {
              this.$set(this.dataList[i], 'total', this.dataList[i].amount * this.dataList[i].price)
            }
            if (data.msg === '没有数据！') {
              this.isQuote = true
            } else {
              this.isQuote = false
            }
          }
        })
    }
  }
</script>
<style type="text/scss" rel="stylesheet/scss" lang="scss" scoped>
  @import "../../styles/common";
</style>
